/**
* PrimeNmumbers 
* This program finds prime numbers which are smaller or equal to the inputted from keyboard integer number
* @author Maksym Ryumin
*/

import java.util.*;
import java.util.ArrayList; 
public class PrimeNumbers{
	
	public static void main(String[] args) {  
        System.out.print("Please, enter an integer number  ");
		  
		Scanner in = new Scanner(System.in);
		  		  
        boolean primeNumberFlag;	  
		 
        boolean checkForIntInput = in.hasNextInt();
		  
		ArrayList<Integer> primeNumbersArray = new ArrayList<Integer>();

        if(checkForIntInput == true) {
            int userIput = in.nextInt();

            if(userIput >= 2) {
                primeNumbersArray.add(2);
				  
                for(int i = 3;i <= userIput;i++) {
		            primeNumberFlag = true;
				  
                    for(int k = 0; k < primeNumbersArray.size(); k++) {
                        if((i % primeNumbersArray.get(k)) == 0) { 
                            primeNumberFlag = false;
				        }
			        }
				    if (primeNumberFlag == true) {
                        primeNumbersArray.add(i);	
                    }					  
                }
                System.out.println("Prime numbers are: " + primeNumbersArray);
            } else
                  System.out.println("There are no Prime numbers.");
        } else 
              System.out.println("Failed! Only integer numbers are accepted.");
          
  	  }
	}
